/** Login.java */

package edu.gatech.applications;



import java.io.Serializable;

import edu.gatech.userclasses.User;
import edu.gatech.utilities.Persistence;
/**
 * @author 512's
 *
 * @version $Revision: 1.0 $
 */
public class Login implements Serializable{
	/**
	 * 
	 */
	private static final long serialVersionUID = -9130305609465265079L;

	/** String username is the username*/
	private String username;

	/** String password is password */
	private String password;

	/**
	 * 
	 * @param username
	 * @param password
	 */
	public Login(String username, String password){
		Persistence.load();
		this.username = username;
		this.password = password;
	}

	/**
	 * 
	
	 * @return currentUser
	 */
	public User validate(){
		User currentUser = null;
		for (User u : Persistence.getUserList()){
			if (username.equals(u.getUsername()) && 
					password.equals(u.getPassword())){
				currentUser = u;
			}
		}
		return currentUser;
	}

	/**
	 * @return String
	 */
	public String toString(){
		return username + " is logging in";
	}

	/**
	 * @return the username
	 */
	public String getUsername() {
		return username;
	}

	/**
	 * @param username the username to set
	 */
	public void setUsername(String username) {
		this.username = username;
	}

	/**
	 * @return the password
	 */
	public String getPassword() {
		return password;
	}

	/**
	 * @param password the password to set
	 */
	public void setPassword(String password) {
		this.password = password;
	}
	
}
